#!/bin/bash

# process queries
while true ; do

  # read stdin
  read SUBDOMAIN

  # update timestamp and start application
  if [ -n "$SUBDOMAIN" -a -d "/service/$SUBDOMAIN" ] ; then
    touch "/service/$SUBDOMAIN/timestamp"
    svc -c "/service/$SUBDOMAIN"
  fi

  # lookup failure
  echo "NULL"

done
